<?php
declare (strict_types = 1);
namespace app\course\model\live;

use app\common\model\BaseModel;
use app\common\logic\Attach;

/**
 * 定义直播课时数据模型
 */
class CourseSectionLive extends BaseModel
{
    /**
     * 表名
     * @var string
     */
    protected $name = 'course_section_live';

    /**
     * 定义表主键
     * @var string
     */
    protected $pk = 'room_no';

    /**
     * 额外填充字段
     * @var array
     */
    // protected $append = ['attach'];

    // 自动写入时间
    protected $autoWriteTimestamp = true;

    // 定义字段类型
    protected $type = [
        'create_time'   => 'integer',
        'update_time'   => 'integer',
        'close_time'    => 'integer',
        'cc_live_ids'   => 'array',
        'cc_record_ids' => 'array',
    ];

    /**
     * 关联的附件
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-12-11
     * @return [type]                      [description]
     */
    public function attach()
    {
        return $this->belongsTo(Attach::class, 'attach_id')->bind(['filename','filesize','extension','duration']);
    }

}
